Path: blob/master/Part 3 - Classification/Decision Tree/[R] Decision Tree.ipynb
1009 views
Decision Tree
Data preprocessing
Fitting Decision Tree classifier to the Training set
Predicting the Test set results
Making the Confusion Matrix
classifier made 43 + 23 = 66 correct prediction and 6 + 8 = 14 incoreect predictions.
Visualising the Training set results
Visualising the Test set results
Things to remmember while making decison tree classifier:
Normally it overfits the data. But here in R due to 'rpart' library (a very powerful and famous library), the overfitting is drastically reduced as compare to Decision Tree Model in python.
There is no need to Scale the features as decision tree does not depends on Euclidean distance. We are using Feature Scaling here just to get a plot with better resolution. If you ammit scaling, then for example the above case the vector size will be about 200+ GB which is not possible to plot.
If we dont apply feature scaling (i.e. do not run cell 7 all through cell 9), then we can have a look at the decision tree. For this we just need to run 2 lines of code